Learn R Programming

scran (version 1.0.3)

Get spikes: Construct the spike-in matrix

Description

Identify rows in the SCESet corresponding to spike-in transcripts, and retrieve a matrix of counts or normalized expression values for those rows.

Usage

"spikes"(x, assay="counts") "isSpike"(x) "isSpike"(x) <- value

Arguments

x
A SCESet object with spike-in data in the colData.
assay
A string specifying whether counts or normalized expression values are to be extracted.
value
A logical vector specifying which rows correspond to spike-ins.

Value

For spikes, a numeric matrix of counts or normalized expression values, with one column per cell and one row per spike-in transcript.For isSpike, a logical vector indicating which rows are spike-ins (or NULL, if this information was not stored in x). For isSpike<-, x is modified to store a spike-specifying vector in fData(x)$is_feature_spike.

Details

This function extracts the spike-in data from x, into a numeric matrix that can be used for downstream analyses. Users should set a logical vector in isSpike(x) indicating whether each row of x is a spike-in control. If assay="exprs", users should have run x through normalize.

See Also

normalize, SCESet

Examples

Run this code
set.seed(100)
popsize <- 10
ngenes <- 1000
all.facs <- 2^rnorm(popsize, sd=0.5)
counts <- matrix(rnbinom(ngenes*popsize, mu=10*all.facs, size=1), ncol=popsize, byrow=TRUE)
spikes <- matrix(rnbinom(100*popsize, mu=10*all.facs, size=0.5), ncol=popsize, byrow=TRUE)

combined <- rbind(counts, spikes)
colnames(combined) <- seq_len(popsize)
rownames(combined) <- seq_len(nrow(combined))
y <- newSCESet(countData=combined)
isSpike(y) <- rep(c(FALSE, TRUE), c(ngenes, 100))

y <- computeSpikeFactors(y)
y <- normalize(y)
spikes(y)[1:10,]
spikes(y, assay="exprs")[1:10,]
isSpike(y)

Run the code above in your browser using DataLab